gdk_pixbuf__png_image_save: removed wrong endian conversion stuff; don't
authorMichael Natterer <mitch@gimp.org>
Tue, 11 Dec 2001 17:30:53 +0000 (17:30 +0000)
committerMichael Natterer <mitch@src.gnome.org>
Tue, 11 Dec 2001 17:30:53 +0000 (17:30 +0000)
2001-12-11  Michael Natterer  <mitch@gimp.org>

* io-png.c: gdk_pixbuf__png_image_save: removed wrong endian
conversion stuff; don't copy RGB pixbufs' lines around before
saving them.

gdk-pixbuf/ChangeLog
gdk-pixbuf/io-png.c

index fa14ebbd09606ddd190670a704db5db70b0db292..c464eb784537e067e39fffacda4e9b79f7d4112a 100644 (file)
@@ -1,3 +1,9 @@
+2001-12-11  Michael Natterer  <mitch@gimp.org>
+
+       * io-png.c: gdk_pixbuf__png_image_save: removed wrong endian
+       conversion stuff; don't copy RGB pixbufs' lines around before
+       saving them.
+
 2001-12-05  Matthias Clasen  <matthiasc@poet.de>
 
        * gdk-pixbuf.h (gdk_pixbuf_ref, gdk_pixbuf_unref,
index b531a75d28f7e5c0ad085f2de807e1029b1d96fb..8d102d94a143d8c2b63f59ba9a3f8ce8c4671719 100644 (file)
@@ -720,10 +720,9 @@ gdk_pixbuf__png_image_save (FILE          *f,
        png_textp text_ptr = NULL;
        guchar *ptr;
        guchar *pixels;
-       int x, y;
-       int i, j;
+       int y;
+       int i;
        png_bytep row_ptr;
-       png_bytep data;
        png_color_8 sig_bit;
        int w, h, rowstride;
        int has_alpha;
@@ -787,8 +786,6 @@ gdk_pixbuf__png_image_save (FILE          *f,
                }
        }
 
-       data = NULL;
-       
        bpc = gdk_pixbuf_get_bits_per_sample (pixbuf);
        w = gdk_pixbuf_get_width (pixbuf);
        h = gdk_pixbuf_get_height (pixbuf);
@@ -823,30 +820,10 @@ gdk_pixbuf__png_image_save (FILE          *f,
                png_set_IHDR (png_ptr, info_ptr, w, h, bpc,
                              PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE,
                              PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
-#ifdef WORDS_BIGENDIAN
-               png_set_swap_alpha (png_ptr);
-#else
-               png_set_bgr (png_ptr);
-#endif
        } else {
                png_set_IHDR (png_ptr, info_ptr, w, h, bpc,
                              PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
                              PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
-               data = g_try_malloc (w * 3 * sizeof (char));
-
-               if (data == NULL) {
-                       /* Check error NULL, normally this would be broken,
-                        * but libpng makes me want to code defensively.
-                        */
-                       if (error && *error == NULL) {
-                               g_set_error (error,
-                                            GDK_PIXBUF_ERROR,
-                                            GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
-                                            _("Insufficient memory to save PNG file"));
-                       }
-                       png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
-                       return FALSE;
-               }
        }
        sig_bit.red = bpc;
        sig_bit.green = bpc;
@@ -859,21 +836,11 @@ gdk_pixbuf__png_image_save (FILE          *f,
 
        ptr = pixels;
        for (y = 0; y < h; y++) {
-               if (has_alpha)
-                       row_ptr = (png_bytep)ptr;
-               else {
-                       for (j = 0, x = 0; x < w; x++)
-                               memcpy (&(data[x*3]), &(ptr[x*3]), 3);
-
-                       row_ptr = (png_bytep)data;
-               }
+               row_ptr = (png_bytep)ptr;
                png_write_rows (png_ptr, &row_ptr, 1);
                ptr += rowstride;
        }
 
-       if (data)
-               g_free (data);
-
        png_write_end (png_ptr, info_ptr);
        png_destroy_write_struct (&png_ptr, (png_infopp) NULL);